﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange;
using Microsoft.Exchange.WebServices;

namespace FolderCalendar
{ 
    [SerializableAttribute()]
    public class User
    {
        private string m_name;
        private string m_mail;
        private string m_sSyncState;
        private SortedList<string, string> m_connectedItemIds = new SortedList<string, string>();
        
        public string Name
        {
            get { return m_name; }
            set { m_name = value; } 
        }
        public string Mail
        {
            get { return m_mail; }
            set { m_mail = value; }
        }
        public string SyncState 
        {
            get { return m_sSyncState; }
            set { m_sSyncState = value; }
        }
                
        /// <summary>
        /// Initializes new user
        /// </summary>
        /// <param name="namex">System name of new user</param>
        /// <param name="mailx">E-mail adress of new user</param>
        public User(string namex, string mailx) 
        {
            this.m_name = namex;
            this.m_mail = mailx;
            this.m_sSyncState = null;
        }
        /// <summary>
        /// Gets ItemId on destination Exchange Server associated with ItemId key on source Exchange Server
        /// </summary>
        /// <param name="sourceItemId">ItemId on source server</param>
        /// <returns>ItemId on destination server</returns>
        public ItemId GetConnectedItemId(string sourceItemId)
        {
            foreach (KeyValuePair<string, string> item in m_connectedItemIds)
            {
                if(item.Key == sourceItemId)
                {
                    return item.Value;
                }
            }
            return null;
        }
        /// <summary>
        /// Adds ItemId pair
        /// </summary>
        /// <param name="source">ItemId on source server</param>
        /// <param name="destination">ItemId on destination server</param>
        public void AddConnectedItemIs(string source, string destination) 
        {
            m_connectedItemIds.Add(source, destination);
        }
        /// <summary>
        /// Deletes ItemId pair
        /// </summary>
        /// <param name="source">ItemId on source server</param>
        public void DeleteConnectedItemIds(string source) 
        {
            m_connectedItemIds.Remove(source);
        }
    }
}
